using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace org.synthful.Windows.Forms
{
    public class TreeListView : TreeView
    {
        public TreeListView()
        {
            this.NodeMouseClick += whenNodeMouseClick;
            this.NodeList = new ListView();
        }

        public ListView NodeList;
        public TreeViewNode Origin;

        new void whenNodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (typeof(TreeViewNode).IsAssignableFrom(e.Node.GetType()))
            {
                TreeViewNode treenode = (TreeViewNode)e.Node;
                if (!treenode.UpToDate)
                    treenode.attachSubNodes();
            }
        }

        virtual public void populateTree(string urlstring)
        {
        }

        virtual public void addNodeListColumnTitles(string[] coltitles)
        {
            foreach (string title in coltitles)
                this.NodeList.Columns.Add(title);
        }

        virtual public void showNode(TreeViewNode node)
        {
            this.NodeList.Items.Clear();
            this.NodeList.Items.AddRange(node.ListViewItems.ToArray());

        }

        virtual public void setOrigin(TreeViewNode node)
        {
            this.Nodes.Add(node);
            this.Origin = node;
        }
    }

}
